/**
 * @param {string} s
 * @param {number} k
 * @return {string}
 */
var reverseStr = function(s, k) {
    let list = []
    while(true){
        if(s.slice(list.length*k,list.length*k+k)){
            list.push(s.slice(list.length*k,list.length*k+k))
        }else{
            break
        }
    }
    let str = ''
    list.forEach((item,index)=>{
        if(index%2==0){
            str = str + item.split('').reverse().join("")
        }else{
            str = str + item
        }
    })
    return str
};

reverseStr('abcdefg',2)